﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WorkEnter.aspx.cs" Inherits="WorkRecord.WorkEnter" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>录入工作信息</title>
    <script src="/Static/js/jquery-1.11.1.min.js"></script>
    <link href="/Static/css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <br />
        <div class="center" style="width: 80%;">
            <asp:TextBox ID="txtGuid" Visible="false" runat="server"></asp:TextBox>
            <table width="100%" border="0" cellspacing="1" cellpadding="0" class="tabline">
                <tr>
                    <td colspan="2" align="center" style="height: 30px;">
                        <h3>
                            工作日记录入</h3>
                    </td>
                </tr>
                <tr>
                    <td class="tdcolor" style="width: 15%;" align="center">
                        今日所在城市：
                    </td>
                    <td>
                        <asp:Repeater ID="rptToDay" runat="server" OnItemCommand="rptToDay_ItemCommand">
                            <ItemTemplate>
                                &nbsp;
                                <asp:TextBox ID="TextBox1" Text='<%#Eval("Area") %>' CssClass="inp_b js_today_exist"
                                    runat="server" Enabled="false" Style="color: Black; width: 120px;"></asp:TextBox>
                                <asp:ImageButton ImageUrl="/Static/img/del-icon.gif" CommandName="del" CommandArgument='<%#Eval("ID") 
%>' ID="btnDelToDay" runat="server" />
                                &nbsp; &nbsp;
                            </ItemTemplate>
                        </asp:Repeater>
                        &nbsp;
                        <asp:TextBox ID="txtToDayArea" Style="width: 120px;" runat="server" CssClass="inp_b js_tb"></asp:TextBox>
                        <asp:ImageButton ImageUrl="/Static/img/add-icon.gif" ID="btnAddToDay" OnClick="btnAddToDay_Click"
                            runat="server" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <table width="100%" cellpadding="0" cellspacing="1" border="0" class="tabline">
                            <tr>
                                <td class="tdcolor" style="width: 18%" align="center">
                                    时间段
                                </td>
                                <td class="tdcolor" style="width: 15%" align="center">
                                    类别
                                </td>
                                <td class="tdcolor" style="width: 65%" align="center">
                                    内容
                                </td>
                                <td class="tdcolor">
                                    &nbsp;
                                </td>
                            </tr>
                            <asp:Repeater ID="rptContent" runat="server" OnItemCommand="rptContent_ItemCommand">
                                <ItemTemplate>
                                    <tr>
                                        <td align="center">
                                            <%#Eval("StartHour") %>
                                            -
                                            <%#Eval("EndHour") %>
                                        </td>
                                        <td align="center">
                                            <%#Eval("WorkType") %>
                                        </td>
                                        <td class="js_content_exist" style="word-wrap:break-word;word-break:break-all">
                                            <%#Eval("Contents")%>
                                        </td>
                                        <td>
                                            <asp:ImageButton ImageUrl="/Static/img/del-icon.gif" CommandName="del" CommandArgument='<%#Eval("ID") %>'
                                                ID="btnContentDel" runat="server" />
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                            <tr>
                                <td align="center">
                                    <asp:DropDownList ID="ddlStartH" runat="server" AutoPostBack="false" OnSelectedIndexChanged="ddlStartH_SelectedIndexChanged">
                                        <%--<asp:ListItem Text="9:30"></asp:ListItem>--%>
                                    </asp:DropDownList>
                                    -
                                    <asp:DropDownList ID="ddlEndH" runat="server">
                                    </asp:DropDownList>
                                </td>
                                <td align="center">
                                    <asp:DropDownList ID="ddlType" runat="server" Style="width: 98%;">
                                    </asp:DropDownList>
                                </td>
                                <td align="center">
                                    <asp:TextBox runat="server" ID="txtContent" TextMode="MultiLine" Style="width: 98%;"
                                        Rows="2" onpropertychange="ResizeTextarea(this)" oninput="ResizeTextarea(this)"
                                        onkeyup="ResizeTextarea(this)"></asp:TextBox>
                                </td>
                                <td align="center">
                                    <asp:ImageButton ImageUrl="/Static/img/add-icon.gif" ID="btnContentAdd" OnClick="btnContentAdd_Click"
                                        runat="server" />
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td class="tdcolor" align="center">
                        下一工作日所在城市：
                    </td>
                    <td>
                        <asp:Repeater ID="rptTomorrow" runat="server" OnItemCommand="rptTomorrow_ItemCommand">
                            <ItemTemplate>
                                &nbsp;
                                <asp:TextBox ID="TextBox2" Text='<%#Eval("Area") %>' CssClass="inp_b js_tomorrow_exist"
                                    runat="server" Enabled="false" Style="color: Black; width: 120px;"></asp:TextBox>
                                <asp:ImageButton ImageUrl="/Static/img/del-icon.gif" CommandName="del" CommandArgument='<%#Eval("ID") 
%>' ID="btnDelToMorrow" runat="server" />
                                &nbsp;&nbsp;
                            </ItemTemplate>
                        </asp:Repeater>
                        &nbsp;
                        <asp:TextBox ID="txtTomorrowArea" Style="width: 120px;" CssClass="inp_b js_tb" runat="server"></asp:TextBox>
                        <asp:ImageButton ImageUrl="/Static/img/add-icon.gif" ID="btnAddTomorrow" OnClick="btnAddTomorrow_Click"
                            runat="server" />
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="center" class="tabbt">
                        <asp:Button ID="btnSubmit" runat="server" CssClass="js_btn" Text="提 交" OnClick="btnSubmit_Click" />
                        <%--<asp:Button ID="bnReset" runat="server" CssClass="submit_m" Text="重 置" OnClick="bnReset_Click" />--%>
                        <input type="button" id="btn_reload" value="重 置" />
                         <input type="button" id="btnBack" onclick='window.location.href = "/WorkView.aspx"' value="返 回" />
                        <input type="reset" id="btn_reset" style="display: none;" />
                    </td>
                </tr>
            </table>
        </div><br />
    </form>
</body>
</html>
<script type="text/javascript">
    // 最小高度 
    var minHeight = 40;
    // 最大高度，超过则出现滚动条 
    var maxHeight = 3000;
    function ResizeTextarea(Control) {
        var t = Control;
        var h = t.scrollHeight;
        h = h > minHeight ? h : minHeight;
        h = h > maxHeight ? maxHeight : h;
        t.style.height = h + "px";
    }

    $(function () {
        if ($(".js_tb").val() == "" || $(".js_tb").val() == "所在城市") {
            $(".js_tb").val("所在城市");
            $(".js_tb").css("color", "gray");
        }
        else
            $(".js_tb").css("color", "black");
        $(".js_tb").focus(function () {
            if ($(this).val() == "所在城市") {
                $(this).val("");
                $(this).css("color", "black");
            }
        });
        $(".js_tb").blur(function () {
            if ($(this).val() == "所在城市" || $(this).val() == "") {
                $(this).val("所在城市");
                $(this).css("color", "gray");
            }
        });

        $("#btn_reload").click(function () {
            $("#btn_reset").click();
            if ($(".js_tb").val() == "" || $(".js_tb").val() == "所在城市") {
                $(".js_tb").val("所在城市");
                $(".js_tb").css("color", "gray");
            }
            else
                $(".js_tb").css("color", "black");
        });


        $(".js_btn").click(function () {
            try {
                var today = $("#<%=txtToDayArea.ClientID %>").val();
                var tomorrow = $("#<%=txtTomorrowArea.ClientID %>").val();
                var content = $("#<%=txtContent.ClientID %>").val();
                var startH = $("#<%=ddlStartH.ClientID %>").get(0).selectedIndex;
                var endH = $("#<%=ddlEndH.ClientID %>").get(0).selectedIndex;
            }
            catch (e) {; }
            var today_exist = $(".js_today_exist").length;
            var tomorrow_exist = $(".js_tomorrow_exist").length;
            var content_exist = $(".js_content_exist").length;
            if ((today == "" || today == "所在城市") && today_exist == 0) {
                alert("请将信息填写完整");
                return false;
            }
            if ((tomorrow == "" || tomorrow == "所在城市") && tomorrow_exist == 0) {
                alert("请将信息填写完整");
                return false;
            }
            if (content == "" && content_exist == 0) {
                alert("请将信息填写完整");
                return false;
            }
            if (content != "") {
                if (startH >= endH) {
                    alert("结束时间应该大于开始时间");
                    return false;
                }
            }
            return true;
        });

        $("#<%=btnAddToDay.ClientID %>").click(function () {
            try {
                var today = $("#<%=txtToDayArea.ClientID %>").val();
            }
            catch (e) {; }
            if (today == "" || today == "所在城市") {
                alert("请输入今日所在城市");
                return false;
            }
            return true;
        });

        $("#<%=btnAddTomorrow.ClientID %>").click(function () {
            try {
                var tomorrow = $("#<%=txtTomorrowArea.ClientID %>").val();
            }
            catch (e) {; }
            if (tomorrow == "" || tomorrow == "所在城市") {
                alert("请输入下一工作日所在城市");
                return false;
            }
            return true;
        });

        $("#<%=btnContentAdd.ClientID %>").click(function () {
            try {
                var content = $("#<%=txtContent.ClientID %>").val();
                var startH = $("#<%=ddlStartH.ClientID %>").get(0).selectedIndex;
                var endH = $("#<%=ddlEndH.ClientID %>").get(0).selectedIndex;
            }
            catch (e) {; }
            if (content == "") {
                alert("请输入内容");
                return false;
            }
            if (startH >= endH) {
                alert("结束时间应该大于开始时间");
                return false;
            }

            return true;
        });


    });
</script>
